using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace Krile.Imported.Snippets
{
    static partial class Drawing
    {
        static public class PathExtensions
        {
            /// <summary>
            /// create circular rectangle path
            /// </summary>
            /// <param name="source">source rectangle</param>
            /// <returns>graphics path</returns>
            /// <remarks>
            /// Reference:http://youryella.wankuma.com/Library/Extensions/Control/CurveBorderDraw.aspx
            /// </remarks>
            static public GraphicsPath GetCircularRectanglePathFromRectangle(Rectangle r, Size circleSize)
            {
                int w = circleSize.Width;
                int h = circleSize.Height;
                GraphicsPath gp = new GraphicsPath();
                gp.StartFigure();
                gp.AddArc(r.Right - w, r.Top, w, h, 270, 90); //right-top
                gp.AddArc(r.Right - w, r.Bottom - h, w, h, 0, 90); // right-bottom
                gp.AddArc(r.Left, r.Bottom - h, w, h, 90, 90); // left-bottom
                gp.AddArc(r.Left, r.Top, w, h, 180, 90); // left-top
                gp.CloseFigure();
                return gp;
            }

        }
    }
}
